# -*- coding: utf-8 -*-
#!/usr/bin/env python3
"""
* 仅供学习交流，请在下载后的24小时内完全删除 请勿将任何内容用于商业或非法目的，否则后果自负。
* 猫猫看看 V1.60

* 活动入口,微信打开：
* 如果连接过期了运行一下就出来了最新的入口！
* http://9pw4.dsdtew.shop/haobaobao/auth/58487f291985c5f32c16b3b01b96a912
* 打开活动入口，抓包的任意接口cookies中的Cookie参数
*
* 变量格式：
* 新建同名环境变量
* 变量名：mykkyd
* 变量值：
* # 3000 代表 3毛，后面两个推送参数可不填，那就必须配置全局推送！
* 账号备注#Cookie参数#提现金额如3000#wxpushApptoken#wxpushTopicId
*
* 其他参数说明（脚本最下方填写参数）
* wxpusher全局参数：wxpusherAppToken、wxpusherTopicId
* 具体使用方法请看文档地址：https://wxpusher.zjiecode.com/docs/#/
*
* 也可使用 微信机器人：wechatBussinessKey
*
* 支持支付宝提现：账号备注#Cookie参数#提现金额如3000#wxpushApptoken#wxpushTopicId#支付宝姓名#支付宝账号
* 只想提现支付宝，不想填写其他参数，最少的参数就是：账号备注#Cookie参数###支付宝姓名#支付宝账号
*
* 增加 自定义检测文章等待时间：mykkydReadPostDelay，默认值是 15-20秒
* 增加 精简日志：mykkydReadPureLog，默认值是 true（也就是精简日志，如果需要显示完整的，请设置为 false）
*
* 定时运行每半小时一次
* 达到标准，自动提现
"""
# This file requires Python 3.x and the following dependencies:
# - base64
try:
    import base64
    exec(base64.b64decode('IiIiCiog5LuF5L6b5a2m5Lmg5Lqk5rWB77yM6K+35Zyo5LiL6L295ZCO55qEMjTlsI/ml7blhoXlrozlhajliKDpmaQg6K+35Yu/5bCG5Lu75L2V5YaF5a6555So5LqO5ZWG5Lia5oiW6Z2e5rOV55uu55qE77yM5ZCm5YiZ5ZCO5p6c6Ieq6LSf44CCCiog54yr54yr55yL55yLIFYxLjYwCgoqIOa0u+WKqOWFpeWPoyzlvq7kv6HmiZPlvIDvvJoKKiDlpoLmnpzov57mjqXov4fmnJ/kuobov5DooYzkuIDkuIv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kZS5jb20vYXBpL3NlbmQvbWVzc2FnZSIKICAgIHRyeToKICAgICAgICBwID0gcmVxdWVzdHMucG9zdCh1cmw9dXJscHVzdCwganNvbj1kYXRhcHVzdCwgdmVyaWZ5PUZhbHNlKQogICAgICAgICMgcHJpbnQocCkKICAgICAgICBpZiBwLmpzb24oKVsiY29kZSJdID09IDEwMDA6CiAgICAgICAgICAgIHByaW50KCLinIUg5o6o6YCB5paH56ug5Yiw5b6u5L+h5oiQ5Yqf77yM6K+35bC95b+r5YmN5b6A54K55Ye75paH56ug77yM5LiN54S25bCx6buR5Y+35ZWm77yBIikKICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICBlbHNlOgogICAgICAgICAgICBwcmludCgi4p2MIOaOqOmAgeaWh+eroOWIsOW+ruS/oeWksei0pe+8jOWujOeKiuWtkO+8jOimgem7keWPt+S6hu+8gSIpCiAgICAgICAgICAgIHJldHVybiBGYWxzZQogICAgZXhjZXB0OgogICAgICAgIHByaW50KCLinYwg5o6o6YCB5paH56ug5Yiw5b6u5L+h5aSx6LSl77yM5a6M54qK5a2Q77yM6KaB6buR5Y+35LqG77yBIikKICAgICAgICByZXR1cm4gRmFsc2UKCgpkZWYgcHVzaFdlY2hhdEJ1c3NpbmVzcyhyb2JvdEtleSwgbGluayk6CiAgICBkYXRhcHVzdCA9IHsibXNndHlwZSI6ICJ0ZXh0IiwgInRleHQiOiB7ImNvbnRlbnQiOiBsaW5rfX0KICAgICMgcHJpbnQoZGF0YXB1c3QpCiAgICB1cmxwdXN0ID0gImh0dHBzOi8vcXlhcGkud2VpeGluLnFxLmNvbS9jZ2ktYmluL3dlYmhvb2svc2VuZD9rZXk9IiArIHJvYm90S2V5CiAgICB0cnk6CiAgICAgICAgcCA9IHJlcXVlc3RzLnBvc3QodXJsPXVybHB1c3QsIGpzb249ZGF0YXB1c3QsIHZlcmlmeT1GYWxzZSkKICAgICAgICAjIHByaW50KHApCiAgICAgICAgaWYgcC5qc29uKClbImVycmNvZGUiXSA9PSAwOgogICAgICAgICAgICBwcmludCgi4pyFIOaOqOmAgeaWh+eroOWIsOS8geS4muW+ruS/oeaIkOWKn++8gSIpCiAgICAgICAgICAgIHJldHVybiBUcnVlCiAgICAgICAgZWxzZToKICAgICAgICAgICAgcHJpbnQoIuKdjCDmjqjpgIHmlofnq6DliLDkvIHkuJrlvq7kv6HlpLHotKXvvIEiKQogICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgIGV4Y2VwdDoKICAgICAgICBwcmludCgi4p2MIOaOqOmAgeaWh+eroOWIsOS8geS4muW+ruS/oeWksei0pe+8gSIpCiAgICAgICAgcmV0dXJuIEZhbHNlCgoKZGVmIGdldGluZm8obGluayk6CiAgICB0cnk6CiAgICAgICAgciA9IHJlcXVlc3RzLmdldChsaW5rLCB2ZXJpZnk9RmFsc2UpCiAgICAgICAgIyBwcmludChsaW5rLCByLnRleHQpCiAgICAgICAgaHRtbCA9IHJlLnN1YigiXHMiLCAiIiwgci50ZXh0KQogICAgICAgIGJpeiA9IHJlLmZpbmRhbGwoJ3ZhcmJpej0iKC4qPykiXHxcfCcsIGh0bWwpCiAgICAgICAgaWYgYml6ICE9IFtdOgogICAgICAgICAgICBiaXogPSBiaXpbMF0KICAgICAgICBpZiBiaXogPT0gIiIgb3IgYml6ID09IFtdOgogICAgICAgICAgICBpZiAiX19iaXoiIGluIGxpbms6CiAgICAgICAgICAgICAgICBiaXogPSByZS5maW5kYWxsKCJfX2Jpej0oLio/KSYiLCBsaW5rKQogICAgICAgICAgICAgICAgaWYgYml6ICE9IFtdOgogICAgICAgICAgICAgICAgICAgIGJpeiA9IGJpelswXQogICAgICAgIG5pY2tuYW1lID0gcmUuZmluZGFsbCgndmFybmlja25hbWU9aHRtbERlY29kZVwoIiguKj8pIlwpOycsIGh0bWwpCiAgICAgICAgaWYgbmlja25hbWUgIT0gW106CiAgICAgICAgICAgIG5pY2tuYW1lID0gbmlja25hbWVbMF0KICAgICAgICB1c2VyX25hbWUgPSByZS5maW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ovL3tzZWxmLmRvbW5haW5Ib3N0fS8iLAogICAgICAgICAgICAiT3JpZ2luIjogZiJodHRwOi8ve3NlbGYuZG9tbmFpbkhvc3R9IiwKICAgICAgICAgICAgIyAiSG9zdCI6IGYie3NlbGYuZG9tbmFpbkhvc3R9IiwKICAgICAgICAgICAgIkFjY2VwdC1FbmNvZGluZyI6ICJnemlwLCBkZWZsYXRlIiwKICAgICAgICAgICAgIkFjY2VwdC1MYW5ndWFnZSI6ICJ6aC1DTix6aCIsCiAgICAgICAgICAgICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkOyBjaGFyc2V0PVVURi04IiwKICAgICAgICAgICAgIkNvb2tpZSI6IHNlbGYuQ29va2llLAogICAgICAgIH0KICAgICAgICBzZWxmLnNlYyA9IHJlcXVlc3RzLnNlc3Npb24oKQogICAgICAgIHNlbGYuc2VjLnZlcmlmeSA9IEZhbHNlCiAgICAgICAgc2VsZi5zZWMuaGVhZGVycyA9IHNlbGYuaGVhZGVycwogICAgICAgIHNlbGYubGFzdGJpeiA9ICIiCiAgICAgICAgc2VsZi5yZWFkSnVtcFBhdGggPSAiIgogICAgICAgIHNlbGYucmV0cnlSZWFkaW5nID0gRmFsc2UKCiAgICBkZWYgdXNlcl9pbmZvKHNlbGYpOgogICAgICAgIHUgPSBmImh0dHA6Ly97c2VsZi5kb21uYWluSG9zdH0vaGFvYmFvYmFvL3VzZXIiCiAgICAgICAgciA9ICIiCiAgICAgICAgdHJ5OgogICAgICAgICAgICByID0gc2VsZi5zZWMuZ2V0KHUpCiAgICAgICAgICAgIHJqID0gci5qc29uKCkKICAgICAgICAgICAgaWYgcmouZ2V0KCJlcnJjb2RlIikgPT0gMDoKICAgICAgICAgICAgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeiOt+WPluS/oeaBr+aIkOWKn++8jOeUqOaIt0lE5Li6IHtyLmpzb24oKVsnZGF0YSddWyd1c2VyaWQnXX0iKQogICAgICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeiOt+WPlueUqOaIt+S/oeaBr+Wksei0pe+8jOi0puWPt+W8guW4uCDmiJbogIUgQ29va2ll5peg5pWI77yM6K+35qOA5rWLQ29va2ll5piv5ZCm5q2j56GuIikKICAgICAgICAgICAgICAgIHJldHVybiBGYWxzZQogICAgICAgIGV4Y2VwdDoKICAgICAgICAgICAgcHJpbnQoci50ZXh0KQogICAgICAgICAgICBwcmludChmIui0puWPt1t7c2VsZi5uYW1lfV3ojrflj5bnlKjmiLfkv6Hmga/lpLHotKUsQ29va2ll5peg5pWI77yM6K+35qOA5rWLQ29va2ll5piv5ZCm5q2j56GuIikKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCgogICAgZGVmIGdvbGQoc2VsZik6CiAgICAgICAgciA9ICIiCiAgICAgICAgdHJ5OgogICAgICAgICAgICB1ID0gZiJodHRwOi8ve3NlbGYuZG9tbmFpbkhvc3R9L2hhb2Jhb2Jhby93b3JraW5mbyIKICAgICAgICAgICAgciA9IHNlbGYuc2VjLmdldCh1KQogICAgICAgICAgICAjIHByaW50KHIuanNvbigpKQogICAgICAgICAgICByaiA9IHIuanNvbigpCiAgICAgICAgICAgIHNlbGYucmVtYWluX2dvbGQgPSBtYXRoLmZsb29yKGludChyai5nZXQoImRhdGEiKS5nZXQoInJlbWFpbl9nb2xkIikpKQogICAgICAgICAgICBzZWxmLnJlbWFpbiA9IGZsb2F0KHJqLmdldCgiZGF0YSIpLmdldCgicmVtYWluIikpCiAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgZifku4rml6Xlt7Lnu4/pmIXor7vkuoZ7cmouZ2V0KCJkYXRhIikuZ2V0KCJkYXlyZWFkcyIpfeevh+aWh+eroCDlvZPliY3ph5HluIF7cmouZ2V0KCJkYXRhIikuZ2V0KCJyZW1haW5fZ29sZCIpfSDlvZPliY3kvZnpop17c2VsZi5yZW1haW59JwogICAgICAgICAgICApCiAgICAgICAgZXhjZXB0OgogICAgICAgICAgICBwcmludChmIui0puWPt1t7c2VsZi5uYW1lfV3ojrflj5bph5HluIHlpLHotKUiKQogICAgICAgICAgICByZXR1cm4gRmFsc2UKCiAgICBkZWYgZ2V0S2V5KHNlbGYpOgogICAgICAgIHVrID0gIiIKICAgICAgICB1a1JlcyA9IE5vbmUKICAgICAgICBmb3IgaSBpbiByYW5nZSgxMCk6CiAgICAgICAgICAgIHUgPSBmImh0dHA6Ly97c2VsZi5kb21uYWluSG9zdH17c2VsZi5yZWFkSnVtcFBhdGh9IgogICAgICAgICAgICAjIHByaW50KCLmj5DnpLogZ2V0S2V577yaIiwgdSkKICAgICAgICAgICAgcCA9IGYiIgogICAgICAgICAgICByID0gcmVxdWVzdHMucG9zdCh1LCBoZWFkZXJzPXNlbGYuaGVhZGVycywgZGF0YT1wLCB2ZXJpZnk9RmFsc2UpCiAgICAgICAgICAgICMgcHJpbnQoImdldEtlee+8miIsIHIudGV4dCkKICAgICAgICAgICAgcmogPSByLmpzb24oKQogICAgICAgICAgICBkb21haW4gPSByai5nZXQoImRhdGEiKS5nZXQoImRvbWFpbiIpCiAgICAgICAgICAgICMgcHJpbnQoIuivt+axguS4rei9rOmhte+8miIsIHIudGV4dCkKICAgICAgICAgICAgcHAgPSBwYXJzZV9xcyh1cmxwYXJzZShkb21haW4pLnF1ZXJ5KQogICAgICAgICAgICBobiA9IHVybHBhcnNlKGRvbWFpbikubmV0bG9jCiAgICAgICAgICAgIHVrID0gcHAuZ2V0KCJ1ayIpWzBdCiAgICAgICAgICAgIHVrUmVzID0gci50ZXh0CiAgICAgICAgICAgIGlmIHVrOgogICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICBpZiB1ayA9PSAiIjoKICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1d6I635Y+WdWvlpLHotKXvvIzov5Tlm57plJnor6/vvJp7dWtSZXN9IikKICAgICAgICAgICAgcmV0dXJuCiAgICAgICAgdGltZS5zbGVlcCg4KQogICAgICAgIHIgPSByZXF1ZXN0cy5nZXQoCiAgICAgICAgICAgIGRvbWFpbiwKICAgICAgICAgICAgaGVhZGVycz17CiAgICAgICAgICAgICAgICAiQWNjZXB0IjogInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL2F2aWYsaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOSIsCiAgICAgICAgICAgICAgICAiQWNjZXB0LUVuY29kaW5nIjogImd6aXAsIGRlZmxhdGUsIGJyIiwKICAgICAgICAgICAgICAgICJBY2NlcHQtTGFuZ3VhZ2UiOiAiemgtQ04semg7cT0wLjkiLAogICAgICAgICAgICAgICAgIkNvbm5lY3Rpb24iOiAia2VlcC1hbGl2ZSIsCiAgICAgICAgICAgICAgICAiSG9zdCI6IGYie2hufSIsCiAgICAgICAgICAgICAgICAiU2VjLUZldGNoLURlc3QiOiAiZG9jdW1lbnQiLAogICAgICAgICAgICAgICAgIlNlYy1GZXRjaC1Nb2RlIjogIm5hdmlnYXRlIiwKICAgICAgICAgICAgICAgICJTZWMtRmV0Y2gtU2l0ZSI6ICJub25lIiwKICAgICAgICAgICAgICAgICJTZWMtRmV0Y2gtVXNlciI6ICI/MSIsCiAgICAgICAgICAgICAgICAiVXBncmFkZS1JbnNlY3VyZS1SZXF1ZXN0cyI6ICIxIiwKICAgICAgICAgICAgICAgICJVc2VyLUFnZW50IjogIk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMDcuMC4wLjAgU2FmYXJpLzUzNy4zNiBOZX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AgICBzeXMuZXhpdCgwKQogICAgICAgIGVsc2U6CiAgICAgICAgICAgICMgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+WHhuWkh+WujOaIkO+8mnt1a33vvIzmj5Dlj5bliLDnmoTlnLDlnYDvvJp7ZG9tYWlufSIpCiAgICAgICAgICAgIGlmIG15a2t5ZFJlYWRQdXJlTG9nID09IEZhbHNlOgogICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgZiLotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+WHhuWkh+aIkOWKn++8jOW9k+WJjeaOpeWPo+eJiOacrOS4uu+8mntyZWFkSnNWZXJzaW9ufSDljbPlsIblvIDlp4vpmIXor7sg4pyFIO+8jOmYheivu+WPguaVsOS4uu+8mnt1a30iCiAgICAgICAgICAgICAgICApCiAgICAgICAgaCA9IHsKICAgICAgICAgICAgIkFjY2VwdCI6ICJhcHBsaWNhdGlvbi9qc29uLCB0ZXh0L2phdmFzY3JpcHQsICovKjsgcT0wLjAxIiwKICAgICAgICAgICAgIkFjY2VwdC1FbmNvZGluZyI6ICJnemlwLCBkZWZsYXRlLCBiciIsCiAgICAgICAgICAgICJBY2NlcHQtTGFuZ3VhZ2UiOiAiemgtQ04semg7cT0wLjkiLAogICAgICAgICAgICAiQ29ubmVjdGlvbiI6ICJrZWVwLWFsaXZlIiwKICAgICAgICAgICAgIkhvc3QiOiBobiwKICAgICAgICAgICAgIk9yaWdpbiI6IGYiaHR0cHM6Ly97aG59IiwKICAgICAgICAgICAgIlNlYy1GZXRjaC1EZXN0IjogImVtcHR5IiwKICAgICAgICAgICAgIlNlYy1GZXRjaC1Nb2RlIjogImNvcnMiLAogICAgICAgICAgICAiU2VjLUZldGNoLVNpdGUiOiAiY3Jvc3Mtc2l0ZSIsCiAgICAgICAgICAgICJVc2VyLUFnZW50IjogIk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMDcuMC4wLjAgU2FmYXJpLzUzNy4zNiBOZXRUeXBlL1dJRkkgTWljcm9NZXNzZW5nZXIvNy4wLjIwLjE3ODEoMHg2NzAwMTQzQikgV2luZG93c1dlY2hhdCgweDYzMDkwNzFkKSBYV0VCLzg0NjEgRmx1ZSIsCiAgICAgICAgfQogICAgICAgIHJldHVybiB1aywgaAoKICAgIGRlZiByZWFkKHNlbGYpOgogICAgICAgIGluZm8gPSBzZWxmLmdldEtleSgpCiAgICAgICAgaWYgbGVuKGluZm8pID09IDA6CiAgICAgICAgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeiOt+WPlumYheivu+WPguaVsOWksei0pe+8jOWBnOatouW+gOWQjumYheivu++8geKaoO+4jyAiKQogICAgICAgICAgICByZXR1cm4KICAgICAgICAjIHByaW50KGluZm8pCiAgICAgICAgdGltZS5zbGVlcCgyKQogICAgICAgIGFyY3RpbGVUaW1lID0gMQogICAgICAgIHNlbGYucmV0cnlSZWFkaW5nID0gRmFsc2UKICAgICAgICB3aGlsZSBUcnVlOgogICAgICAgICAgICByZXMgPSB7ImVycmNvZGUiOiAtMX0KICAgICAgICAgICAgIyByYXdSZXMgPSAiIgogICAgICAgICAgICByZWZyZXNoVGltZSA9IDAKICAgICAgICAgICAgd2hpbGUgcmVzWyJlcnJjb2RlIl0gIT0gMDoKICAgICAgICAgICAgICAgIHNlbGYucmV0cnlSZWFkaW5nID0gRmFsc2UKICAgICAgICAgICAgICAgIHRpbWVTdGFtcCA9IHN0cih0cygpKQogICAgICAgICAgICAgICAgbXlzaWduID0gaGFzaGxpYi5tZDUoCiAgICAgICAgICAgICAgICAgICAgKGluZm9bMV1bIkhvc3QiXSArIHRpbWVTdGFtcCArICJMaio/UTMjcE92aVciKS5lbmNvZGUoKQogICAgICAgICAgICAgICAgKS5oZXhkaWdlc3QoKQogICAgICAgICAgICAgICAgc2VsZi5wYXJhbXMgPSB7CiAgICAgICAgICAgICAgICAgICAgInVrIjogaW5mb1swXSwKICAgICAgICAgICAgICAgICAgICAidGltZSI6IHRpbWVTdGFtcCwKICAgICAgICAgICAgICAgICAgICAibXlzaWduIjogbXlzaWduLAogICAgICAgICAgICAgICAgICAgICJ2IjogIjUuMCIsCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB1ID0gZiJodHRwczovL25zci56c2YyMDIzZTQ1OC5jbG91ZC9oYW9iYW9iYW8vbWt3ZW56aGFuZ3MiCiAgICAgICAgICAgICAgICAjIHByaW50KAogICAgICAgICAgICAgICAgIyAgICAgIumYheivu+aWh+eroOWPguaVsOafpeeci++8miIsCiAgICAgICAgICAgICAgICAjICAgICB1LAogICAgICAgICAgICAgICAgIyAgICAgc2VsZi5wYXJhbXMsCiAgICAgICAgICAgICAgICAjICAgICBpbmZvLAogICAgICAgICAgICAgICAgIyAgICAgaW5mb1sxXVsiT3JpZ2luIl0ucmVwbGFjZSgiaHR0cHM6Ly8iLCAiIikucmVwbGFjZSgiLyIsICIiKSwKICAgICAgICAgICAgICAgICMgKQogICAgICAgICAgICAgICAgciA9IHJlcXVlc3RzLmdldCgKICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgIGhlYWRlcnM9aW5mb1sxXSwKICAgICAgICAgICAgICAgICAgICBwYXJhbXM9c2VsZi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgdmVyaWZ5PUZhbHNlLAogICAgICAgICAgICAgICAgICAgIHRpbWVvdXQ9NjAsCiAgICAgICAgICAgICAgICAgICAgcHJveGllcz1wcm94aWVzLAogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgcHJpbnQoIi0iICogNTApCiAgICAgICAgICAgICAgICAjIGlmIG15a2t5ZFJlYWRQdXJlTG9nID09IEZhbHNlOgogICAgICAgICAgICAgICAgIyAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAjICAgIGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeesrFt7cmVmcmVzaFRpbWUrMX1d5qyh6I635Y+W6ZiF6K+75paH56ugW3tpbmZvWzBdfV3nm67nmoTpobXvvJp7ci50ZXh0fSIKICAgICAgICAgICAgICAgICMgKQogICAgICAgICAgICAgICAgIyByYXdSZXMgPSByLnRleHQKICAgICAgICAgICAgICAgICMgcHJpbnQoIuiOt+WPluaWh+eroOmYheivu+mTvuaOpe+8miIsIHUsIGluZm9bMV0sIHIudGV4dCkKICAgICAgICAgICAgICAgIGlmIHIudGV4dCBhbmQgci5qc29uKClbImVycmNvZGUiXSA9PSAwOgogICAgICAgICAgICAgICAgICAgIHJlcyA9IHIuanNvbigpCiAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgIGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeesrFt7cmVmcmVzaFRpbWUrMX1d5qyh6I635Y+W56ysW3thcmN0aWxlVGltZX1d56+H6ZiF6K+75paH56ugW3tpbmZvWzBdfV3ot7Povazpk77mjqXmiJDlip8iCiAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICBkZWNvZGVkX3N0ciA9IGpzb24ubG9hZHMoci50ZXh0KQogICAgICAgICAgICAgICAgICAgIGlmIGRlY29kZWRfc3RyWyJtc2ciXToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIui0puWPt1t7c2VsZi5uYW1lfV3nrKxbe3JlZnJlc2hUaW1lKzF9XeasoeiOt+WPluesrFt7YXJjdGlsZVRpbWV9Xeevh+mYheivu+aWh+eroFt7aW5mb1swXX1d6Lez6L2s6ZO+5o6l5aSx6LSl77yae2RlY29kZWRfc3RyWydtc2cnXX0iCiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICAgICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIui0puWPt1t7c2VsZi5uYW1lfV3nrKxbe3JlZnJlc2hUaW1lKzF9XeasoeiOt+WPluesrFt7YXJjdGlsZVRpbWV9Xeevh+mYheivu+aWh+eroFt7aW5mb1swXX1d6Lez6L2s6ZO+5o6l5aSx6LSl77yae3IudGV4dH0iCiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgIHRpbWUuc2xlZXAoMS41KQogICAgICAgICAgICAgICAgcmVmcmVzaFRpbWUgPSByZWZyZXNoVGltZSArIDEKICAgICAgICAgICAgICAgIGlmIHJlZnJlc2hUaW1lID49IDU6CiAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLimqDvuI8g6LSm5Y+3W3tzZWxmLm5hbWV9XeiOt+WPlumYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroFt7aW5mb1swXX1d6LaF5pe24oCm4oCmIikKICAgICAgICAgICAgICAgICAgICByZXR1cm4KICAgICAgICAgICAgd2VjaGF0UG9zdExpbmsgPSAiIgogICAgICAgICAgICBpZiByZXMuZ2V0KCJlcnJjb2RlIikgPT0gMDoKICAgICAgICAgICAgICAgIHJldHVybkxpbmsgPSAiIgogICAgICAgICAgICAgICAgdHJ5OgogICAgICAgICAgICAgICAgICAgIHJldHVybkxpbmsgPSByZXMuZ2V0KCJkYXRhIikuZ2V0KCJsaW5rIikKICAgICAgICAgICAgICAgIGV4Y2VwdCBFeGNlcHRpb24gYXMgZToKICAgICAgICAgICAgICAgICAgICBlcnJvck1zZyA9IHJlcy5nZXQoImRhdGEiKQogICAgICAgICAgICAgICAgICAgICMgcHJpbnQoIjHmiqXplJnvvJoiLCBlKQogICAgICAgICAgICAgICAgICAgICMgcHJpbnQoIjHov5Tlm57vvJoiLCByYXdSZXMpCiAgICAgICAgICAgICAgICAgICAgaWYgIjQwNCBOb3QgRm91bmQiIGluIGVycm9yTXNnOgogICAgICAgICAgICAgICAgICAgICAgICBlcnJvck1zZyA9ICLlj7DlrZDmjqXlj6PkuI3ooYzvvIzltKnkuoZ+IgogICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnJldHJ5UmVhZGluZyA9IFRydWUKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIuKaoO+4jyDotKblj7dbe3NlbGYubmFtZX1d6I635Y+W6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV3pk77mjqXlpLHotKXvvIznlpHkvLzlj7DlrZDmjqXlj6PlpKrlnoPlnL7vvIzltKnkuobvvIzov5Tlm57mlbDmja7kuLrvvJoiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JNc2csCiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgICAgICAgICBwcmludCgKICAgICAgICAgICAgICAgICAgICAgICAgZiLimqDvuI8g6LSm5Y+3W3tzZWxmLm5hbWV9XeiOt+WPlumYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroFt7aW5mb1swXX1d6ZO+5o6l5aSx6LSl77yM55aR5Ly85Y+w5a2Q5o6l5Y+j5aSq5Z6D5Zy+77yM5bSp5LqG77yM6L+U5Zue5pWw5o2u5Li677yaIiwKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JNc2csCiAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgICAgICAgICBpZiAibXAud2VpeGluLnFxLmNvbSIgaW4gcmV0dXJuTGluazoKICAgICAgICAgICAgICAgICAgICBpZiBteWtreWRSZWFkUHVyZUxvZyA9PSBGYWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+W+ruS/oeaWh+eroO+8mntyZXR1cm5MaW5rfSIpCiAgICAgICAgICAgICAgICAgICAgd2VjaGF0UG9zdExpbmsgPSByZXR1cm5MaW5rCiAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgICMgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroOWHhuWkh+i3s+i9rO+8mntsaW5rfSIpCiAgICAgICAgICAgICAgICAgICAgd2VjaGF0UG9zdExpbmsgPSBzZWxmLmp1bXAocmV0dXJuTGluaykKICAgICAgICAgICAgICAgICAgICBpZiBteWtreWRSZWFkUHVyZUxvZyA9PSBGYWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIui0puWPt1t7c2VsZi5uYW1lfV0g6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5b6u5L+h5paH56ug77yae3dlY2hhdFBvc3RMaW5rfSIKICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgaWYgbXlra3lkUmVhZFB1cmVMb2cgPT0gRmFsc2U6CiAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroO+8mnt3ZWNoYXRQb3N0TGlua30iKQogICAgICAgICAgICAgICAgcG9zdEluZm8gPSBnZXRpbmZvKHdlY2hhdFBvc3RMaW5rKQogICAgICAgICAgICAgICAgaWYgcG9zdEluZm8gPT0gRmFsc2U6CiAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgIGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV3lm6Ag6I635Y+W5YWs5LyX5Y+35paH56ug5L+h5oGv5LiN5oiQ5Yqf77yM5a+86Ie06ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV0g5aSx6LSl4oCm4oCmIgogICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICAgICAgICAgIHNsZWVwVGltZSA9IHJhbmRvbS5yYW5kaW50KDcsIDEwKQogICAgICAgICAgICAgICAgIyDlpoLmnpzmmK/mo4DmtYvnibnlvoHliLDnmoTmlofnq6Ag5oiW6ICFIOWQjuS4gOevh+aWh+eroOS4juWJjeS4gOevh+ebuOS8vAogICAgICAgICAgICAgICAgaWYgKAogICAgICAgICAgICAgICAgICAgIGNoZWNrRGljdC5nZXQocG9zdEluZm9bNF0pICE9IE5vbmUKICAgICAgICAgICAgICAgICAgICBvciAocmVzLmdldCgiZGF0YSIpLmdldCgiYSIpID09IDIpCiAgICAgICAgICAgICAgICAgICAgb3IgKCImY2hrc209IiBpbiB3ZWNoYXRQb3N0TGluaykKICAgICAgICAgICAgICAgICk6CiAgICAgICAgICAgICAgICAgICAgc2xlZXBUaW1lID0gcmVhZFBvc3REZWxheSBvciByYW5kb20ucmFuZGludCgxNSwgMjApCiAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgIGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV3pmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XSDmo4DmtYvliLDnlpHkvLzmo4DmtYvmlofnq6DvvIzmraPlnKjmjqjpgIHvvIznrYnlvoXov4fmo4DmtYvvvIznrYnlvoXml7bpl7TvvJp7c2xlZXBUaW1lfeenkuOAguOAguOAgiIKICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICAgICAgaWYgc2VsZi53ZWNoYXRCdXNzaW5lc3NLZXk6CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2hXZWNoYXRCdXNzaW5lc3Moc2VsZi53ZWNoYXRCdXNzaW5lc3NLZXksIHdlY2hhdFBvc3RMaW5rKQogICAgICAgICAgICAgICAgICAgIGVsaWYgc2VsZi5hcHBUb2tlbjoKICAgICAgICAgICAgICAgICAgICAgICAgcHVzaCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuYXBwVG9rZW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnRvcGljSWRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIueMq+eMq+eci+eci+mYheivu+i/h+ajgOa1iyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWNoYXRQb3N0TGluaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYi6LSm5Y+3W3tzZWxmLm5hbWV9XemYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroFt7aW5mb1swXX1dIOato+WcqOetieW+hei/h+ajgOa1i++8jOetieW+heaXtumXtO+8mntzbGVlcFRpbWV956eSXG7lubvnlJ/mj5DnpLrvvJrlv6vngrnvvIzliKvogL3mkIHml7bpl7TkuobvvIEiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIm15a2t5ZCIsCiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgICAgICBwcmludCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV3pmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XSDpnIDopoHov4fmo4DmtYvvvIzkvYbmmK/mnKrphY3nva7mjqjpgIF0b2tlbu+8jOS4uuS6humBv+WFjem7keWPt++8jOWBnOatoumYheivu+OAguOAguOAgiIKICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgIGYi4pyFIOi0puWPt1t7c2VsZi5uYW1lfV3pmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XSDpnZ7mo4DmtYvmlofnq6DvvIzmqKHmi5/or7t7c2xlZXBUaW1lfeenkiIKICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICBzZWxmLmxhc3RiaXogPSBwb3N0SW5mb1s0XQogICAgICAgICAgICAgICAgdGltZS5zbGVlcChzbGVlcFRpbWUpCiAgICAgICAgICAgICAgICB1MSA9IGYiaHR0cHM6Ly9uc3IuenNmMjAyM2U0NTguY2xvdWQvaGFvYmFvYmFvL2FkZGdvbGRzMj90aW1lPXtzbGVlcFRpbWV9JnVrPXtpbmZvWzBdfSZwc2lnbj17bXlzaWdufSIKICAgICAgICAgICAgICAgIHIxID0gcmVxdWVzdHMuZ2V0KHUxLCBoZWFkZXJzPWluZm9bMV0sIHZlcmlmeT1GYWxzZSkKICAgICAgICAgICAgICAgIHRyeToKICAgICAgICAgICAgICAgICAgICAjIHByaW50KCLlop7liqDph5HluIHvvJoiLCB1MSwgaW5mb1sxXSwgcjEudGV4dCkKICAgICAgICAgICAgICAgICAgICBpZiByMS50ZXh0IGFuZCByMS5qc29uKCk6CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeToKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYi4pyFIOi0puWPt1t7c2VsZi5uYW1lfV0g6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV3miYDlvpfph5HluIHvvJp7cjEuanNvbigpWydkYXRhJ11bJ2dvbGQnXX3kuKrvvIzotKbmiLflvZPliY3ph5HluIHvvJp7cjEuanNvbigpWydkYXRhJ11bJ2xhc3RfZ29sZCddfeS4qu+8jOS7iuaXpeW3suivu++8mntyMS5qc29uKClbJ2RhdGEnXVsnZGF5X3JlYWQnXX3mrKHvvIzku4rml6XmnKror7sge3IxLmpzb24oKVsnZGF0YSddWydyZW1haW5fcmVhZCddfeevh+aWh+eroCIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiBhcyBlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZiLinYwg6LSm5Y+3W3tzZWxmLm5hbWV9XSDpmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XeW8guW4uO+8mntyMS5qc29uKCkuZ2V0KCdtc2cnKX0iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAi5pys5qyh6ZiF6K+75peg5pWIIiBpbiByMS5qc29uKCkuZ2V0KCJtc2ciKToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhawogICAgICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZiLinYwg6LSm5Y+3W3tzZWxmLm5hbWV9XSDpmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XeWksei0pe+8mntyMS50ZXh0fSIKICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgICAgICBicmVhawogICAgICAgICAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiBhcyBlOgogICAgICAgICAgICAgICAgICAgICMgcHJpbnQoIjLmiqXplJnvvJoiLCBlKQogICAgICAgICAgICAgICAgICAgICMgcHJpbnQoIjLov5Tlm57vvJoiLCByMS50ZXh0KQogICAgICAgICAgICAgICAgICAgIGVycm9yTXNnID0gcjEudGV4dAogICAgICAgICAgICAgICAgICAgIGlmICI0MDQgTm90IEZvdW5kIiBpbiBlcnJvck1zZzoKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JNc2cgPSAi5Y+w5a2Q5o6l5Y+j5LiN6KGM77yM5bSp5LqGfiIKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5yZXRyeVJlYWRpbmcgPSBUcnVlCiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZiLimqDvuI8g6LSm5Y+3W3tzZWxmLm5hbWV9XSDpmIXor7vnrKxbe2FyY3RpbGVUaW1lfV3nr4fmlofnq6Bbe2luZm9bMF19XeW8guW4uO+8jOi/lOWbnuaVsOaNruS4uu+8miIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvck1zZywKICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgICAgICBicmVhawogICAgICAgICAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgICAgICAgICBmIuKaoO+4jyDotKblj7dbe3NlbGYubmFtZX1dIOmYheivu+esrFt7YXJjdGlsZVRpbWV9Xeevh+aWh+eroFt7aW5mb1swXX1d5byC5bi477yM6L+U5Zue5pWw5o2u5Li677yaIiwKICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JNc2csCiAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgICAgIGVsaWYgcmVzLmdldCgiZXJyY29kZSIpID09IDQwNToKICAgICAgICAgICAgICAgIHByaW50KGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV0g6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV3pmIXor7vph43lpI0iKQogICAgICAgICAgICAgICAgdGltZS5zbGVlcCgxLjUpCiAgICAgICAgICAgIGVsaWYgcmVzLmdldCgiZXJyY29kZSIpID09IDQwNzoKICAgICAgICAgICAgICAgIHByaW50KGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV0g6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV3pmIXor7vnu5PmnZ8iKQogICAgICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgIHByaW50KGYi4pqg77iPIOi0puWPt1t7c2VsZi5uYW1lfV0g6ZiF6K+756ysW3thcmN0aWxlVGltZX1d56+H5paH56ugW3tpbmZvWzBdfV3mnKrnn6Xmg4XlhrUiKQogICAgICAgICAgICAgICAgdGltZS5zbGVlcCgxLjUpCiAgICAgICAgICAgIGFyY3RpbGVUaW1lID0gYXJjdGlsZVRpbWUgKyAxCgogICAgZGVmIGp1bXAoc2VsZiwgbGluayk6CiAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1d5byA5aeL5pys5qyh6ZiF6K+74oCm4oCmIikKICAgICAgICBobiA9IHVybHBhcnNlKGxpbmspLm5ldGxvYwogICAgICAgIGggPSB7CiAgICAgICAgICAgICJIb3N0IjogaG4sCiAgICAgICAgICAgICJDb25uZWN0aW9uIjogImtlZXAtYWxpdmUiLAogICAgICAgICAgICAiVXBncmFkZS1JbnNlY3VyZS1SZXF1ZXN0cyI6ICIxIiwKICAgICAgICAgICAgIlVzZXItQWdlbnQiOiAiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwNy4wLjAuMCBTYWZhcmkvNTM3LjM2IE5ldFR5cGUvV0lGSSBNaWNyb01lc3Nlbmdlci83LjAuMjAuMTc4MSgweDY3MDAxNDNCKSBXaW5kb3dzV2VjaGF0KDB4NjMwOTA2MjEpIFhXRUIvOD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dW90ZShzZWxmLmFsaUFjY291bnQpfSZwbmFtZT17cXVvdGUoc2VsZi5hbGlOYW1lKX0iCiAgICAgICAgciA9IHJlcXVlc3RzLnBvc3QoCiAgICAgICAgICAgIHUsCiAgICAgICAgICAgIGhlYWRlcnM9ewogICAgICAgICAgICAgICAgIkFjY2VwdCI6ICJhcHBsaWNhdGlvbi9qc29uLCB0ZXh0L2phdmFzY3JpcHQsICovKjsgcT0wLjAxIiwKICAgICAgICAgICAgICAgICJBY2NlcHQtRW5jb2RpbmciOiAiZ3ppcCwgZGVmbGF0ZSIsCiAgICAgICAgICAgICAgICAiQWNjZXB0LUxhbmd1YWdlIjogInpoLUNOLHpoO3E9MC45IiwKICAgICAgICAgICAgICAgICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkOyBjaGFyc2V0PVVURi04IiwKICAgICAgICAgICAgICAgICJDb29raWUiOiBzZWxmLkNvb2tpZSwKICAgICAgICAgICAgICAgICJIb3N0IjogZiJ7c2VsZi5kb21uYWluSG9zdH0iLAogICAgICAgICAgICAgICAgIk9yaWdpbiI6IGYiaHR0cDovL3tzZWxmLmRvbW5haW5Ib3N0fSIsCiAgICAgICAgICAgICAgICAiUHJveHktQ29ubmVjdGlvbiI6ICJrZWVwLWFsaXZlIiwKICAgICAgICAgICAgICAgICJSZWZlcmVyIjogZiJodHRwOi8ve3NlbGYuZG9tbmFpbkhvc3R9L2hhb2Jhb2Jhby93aXRoZHJhdyIsCiAgICAgICAgICAgICAgICAiWC1SZXF1ZXN0ZWQtV2l0aCI6ICJYTUxIdHRwUmVxdWVzdCIsCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGRhdGE9cCwKICAgICAgICAgICAgdmVyaWZ5PUZhbHNlLAogICAgICAgICkKICAgICAgICBwcmludChmIuKchSDotKblj7dbe3NlbGYubmFtZX1dIOaPkOeOsOe7k+aenO+8miIsIHIuanNvbigpWyJtc2ciXSkKCiAgICBkZWYgd2l0aGRyYXcoc2VsZik6CiAgICAgICAgZ29sZCA9IGludChpbnQoc2VsZi5yZW1haW5fZ29sZCkgLyAxMDAwKSAqIDEwMDAKICAgICAgICBwcmludChmIui0puWPt1t7c2VsZi5uYW1lfV0g5pys5qyh5o+Q546w6YeR6aKdICIsIHNlbGYucmVtYWluLCAi5YWDICIsIGdvbGQsICLph5HluIEiKQogICAgICAgIHdpdGhkcmF3QmFsYW5jZSA9IHJvdW5kKChpbnQoc2VsZi50eGJ6KSAvIDEwMDAwKSwgMykKICAgICAgICBpZiBnb2xkIG9yIChzZWxmLnJlbWFpbiA+PSB3aXRoZHJhd0JhbGFuY2UpOgogICAgICAgICAgICBpZiBnb2xkIGFuZCAoKGZsb2F0KHNlbGYucmVtYWluKSArIGdvbGQgLyAxMDAwMCkgPD0gMzApOgogICAgICAgICAgICAgICAgIyDlvIDlp4vmj5DnjrAKICAgICAgICAgICAgICAgICMg5Lul5LiL6YC76L6R5rKh55So77yM5LiN566h5L2gZ29sZOS4uuWkmuWwke+8jOWug+mDveaYr+WFqOmDqOWFkeaNogogICAgICAgICAgICAgICAgIyBtYXhDYW5FeGNoYW5nZUdvbGQgPSAoMjkuOSAtIHNlbGYucmVtYWluKSAqIDEwMDAwCiAgICAgICAgICAgICAgICAjIGlmIG1heENhbkV4Y2hhbmdlR29sZCA+IDA6CiAgICAgICAgICAgICAgICAjICAgICBnb2xkID0gbWluKG1heENhbkV4Y2hhbmdlR29sZCwgZ29sZCkKICAgICAgICAgICAgICAgICMgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XSDkuLrpgb/lhY3otoXov4fkuInljYHlnZfvvIzmnKzmrKHlhZHmjaLph5HluIHmlbDkuLogIiwgZ29sZCwgIumHkeW4gSIpCiAgICAgICAgICAgICAgICB1MSA9IGYiaHR0cDovL3tzZWxmLmRvbW5haW5Ib3N0fS9oYW9iYW9iYW8vZ2V0Z29sZCIKICAgICAgICAgICAgICAgIHAxID0gZiJyZXF1ZXN0X2lkPXtzZWxmLnJlcXVlc3RfaWR9JmdvbGQ9e2dvbGR9IgogICAgICAgICAgICAgICAgciA9IHJlcXVlc3RzLnBvc3QoCiAgICAgICAgICAgICAgICAgICAgdTEsCiAgICAgICAgICAgICAgICAgICAgZGF0YT1wMSwKICAgICAgICAgICAgICAgICAgICBoZWFkZXJzPXsKICAgICAgICAgICAgICAgICAgICAgICAgIkFjY2VwdCI6ICJhcHBsaWNhdGlvbi9qc29uLCB0ZXh0L2phdmFzY3JpcHQsICovKjsgcT0wLjAxIiwKICAgICAgICAgICAgICAgICAgICAgICAgIkFjY2VwdC1FbmNvZGluZyI6ICJnemlwLCBkZWZsYXRlIiwKICAgICAgICAgICAgICAgICAgICAgICAgIkFjY2VwdC1MYW5ndWFnZSI6ICJ6aC1DTix6aDtxPTAuOSIsCiAgICAgICAgICAgICAgICAgICAgICAgICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkOyBjaGFyc2V0PVVURi04IiwKICAgICAgICAgICAgICAgICAgICAgICAgIkNvb2tpZSI6IHNlbGYuQ29va2llLAogICAgICAgICAgICAgICAgICAgICAgICAiSG9zdCI6IGYie3NlbGYuZG9tbmFpbkhvc3R9IiwKICAgICAgICAgICAgICAgICAgICAgICAgIk9yaWdpbiI6IGYiaHR0cDovL3tzZWxmLmRvbW5haW5Ib3N0fSIsCiAgICAgICAgICAgICAgICAgICAgICAgICJQcm94eS1Db25uZWN0aW9uIjogImtlZXAtYWxpdmUiLAogICAgICAgICAgICAgICAgICAgICAgICAiUmVmZXJlciI6IGYiaHR0cDovL3tzZWxmLmRvbW5haW5Ib3N0fS9oYW9iYW9iYW8vd2l0aGRyYXciLAogICAgICAgICAgICAgICAgICAgICAgICAiVXNlci1BZ2VudCI6ICJNb3ppbGxhLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvMTA3LjAuMC4wIFNhZmFyaS81MzcuMzYgTmV0VHlwZS9XSUZJIE1pY3JvTWVzc2VuZ2VyLzcuMC4yMC4xNzgxKDB4NjcwMDE0M0IpIFdpbmRvd3NXZWNoYXQoMHg2MzA5MDcxZCkgWFdFQi84NDYxIEZsdWUiLAogICAgICAgICAgICAgICAgICAgICAgICAiWC1SZXF1ZXN0ZWQtV2l0aCI6ICJYTUxIdHRwUmVxdWVzdCIsCiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICB2ZXJpZnk9RmFsc2UsCiAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICB0cnk6CiAgICAgICAgICAgICAgICAgICAgcmVzID0gci5qc29uKCkKICAgICAgICAgICAgICAgICAgICBpZiByZXMuZ2V0KCJlcnJjb2RlIikgPT0gMDoKICAgICAgICAgICAgICAgICAgICAgICAgd2l0aGRyYXdCYWxhbmNlTnVtID0gc2VsZi5yZW1haW4gKyBmbG9hdChyZXNbImRhdGEiXVsibW9uZXkiXSkKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIuKchSDotKblj7dbe3NlbGYubmFtZX1dIOmHkeW4geWFkeaNouS4uueOsOmHkeaIkOWKn++8jOW8gOWni+aPkOeOsO+8jOmihOiuoeWIsOi0piB7d2l0aGRyYXdCYWxhbmNlTnVtfSDlhYMgPj4+ICIKICAgICAgICAgICAgICAgICAgICAgICAgKQoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgd2l0aGRyYXdCYWxhbmNlTnVtIDwgd2l0aGRyYXdCYWxhbmNlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1d5rKh5pyJ6L6+5Yiw5o+Q546w5qCH5YeGIHt3aXRoZHJhd0JhbGFuY2V9IOWFgyIpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi53aXRoZHJhd1Bvc3QoKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4KICAgICAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgICAgICBwcmludCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYi6LSm5Y+3W3tzZWxmLm5hbWV9XSDph5HluIHlhZHmjaLkuLrnjrDph5HlpLHotKXvvJoiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgci50ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIiDmj5DnjrDlnLDlnYDvvJoiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdTEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIOaPkOeOsOWPguaVsO+8miIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwMSwKICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiBhcyBlOgogICAgICAgICAgICAgICAgICAgICMgcmFpc2UgZQogICAgICAgICAgICAgICAgICAgICMg5aSE55CG5byC5bi4CiAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOaPkOeOsOWksei0pe+8miIsIGUpCiAgICAgICAgICAgIHNlbGYud2l0aGRyYXdQb3N0KCkKCiAgICBkZWYgaW5pdChzZWxmKToKICAgICAgICB0cnk6CiAgICAgICAgICAgIHIgPSByZXF1ZXN0cy5nZXQoCiAgICAgICAgICAgICAgICBnZXROZXdJbnZpdGVVcmwoKSwKICAgICAgICAgICAgICAgIGhlYWRlcnM9ewogICAgICAgICAgICAgICAgICAgICJVcGdyYWRlLUluc2VjdXJlLVJlcXVlc3RzIjogIjEiLAogICAgICAgICAgICAgICAgICAgICJVc2VyLUFnZW50IjogIk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpI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JDb29raWUiOiBzZWxmLkNvb2tpZSwKICAgICAgICAgICAgIyB9CiAgICAgICAgICAgICMgIyDojrflj5ZyZXF1ZXN0SWQKICAgICAgICAgICAgc2VsZi5yZWFkSnVtcFBhdGggPSAiIgogICAgICAgICAgICBpZiBteWtreWREZXRlY3RpbmdTZWFsU3RhdHVzOgogICAgICAgICAgICAgICAgciA9IHJlcXVlc3RzLmdldCgKICAgICAgICAgICAgICAgICAgICBmImh0dHA6Ly97c2VsZi5kb21uYWluSG9zdH0vaGFvYmFvYmFvL2hvbWUiLAogICAgICAgICAgICAgICAgICAgIGhlYWRlcnM9ewogICAgICAgICAgICAgICAgICAgICAgICAiVXBncmFkZS1JbnNlY3VyZS1SZXF1ZXN0cyI6ICIxIiwKICAgICAgICAgICAgICAgICAgICAgICAgIlVzZXItQWdlbnQiOiAiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwNy4wLjAuMCBTYWZhcmkvNTM3LjM2IE5ldFR5cGUvV0lGSSBNaWNyb01lc3Nlbmdlci83LjAuMjAuMTc4MSgweDY3MDAxNDNCKSBXaW5kb3dzV2VjaGF0KDB4NjMwOTA3MWQpIFhXRUIvODQ2MSBGbHVlIiwKICAgICAgICAgICAgICAgICAgICAgICAgIkFjY2VwdCI6ICJ0ZXh0L2h0bWwsYXBwbGljYXRpb24veGh0bWwreG1sLGFwcGxpY2F0aW9uL3htbDtxPTAuOSxpbWFnZS9hdmlmLGltYWdlL3dlYnAsaW1hZ2UvYXBuZywqLyo7cT0wLjgsYXBwbGljYXRpb24vc2lnbmVkLWV4Y2hhbmdlO3Y9YjM7cT0wLjkiLAogICAgICAgICAgICAgICAgICAgICAgICAiQWNjZXB0LUVuY29kaW5nIjogImd6aXAsIGRlZmxhdGUiLAogICAgICAgICAgICAgICAgICAgICAgICAiQWNjZXB0LUxhbmd1YWdlIjogInpoLUNOLHpoO3E9MC45IiwKICAgICAgICAgICAgICAgICAgICAgICAgIkNvb2tpZSI6IHNlbGYuQ29va2llLAogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgdmVyaWZ5PUZhbHNlLAogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgaHRtbHRleHQgPSByLnRleHQKICAgICAgICAgICAgICAgIHJlYWRfanVtcF9yZWFkX3RleHQgPSBleHRyYWN0X21pZGRsZV90ZXh0KAogICAgICAgICAgICAgICAgICAgIGh0bWx0ZXh0LCAiZnVuY3Rpb24gcmVhZF9qdW1wX3JlYWQoKXsiLCAic3VjY2VzczogZnVuY3Rpb24iCiAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICBpZiByZWFkX2p1bXBfcmVhZF90ZXh0OgogICAgICAgICAgICAgICAgICAgIHJlYWRKdW1wUGF0aCA9IGV4dHJhY3RfbWlkZGxlX3RleHQoCiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRfanVtcF9yZWFkX3RleHQsICJ1cmw6IGRvbWFpbisnIiwgIicsIgogICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICBpZiByZWFkSnVtcFBhdGg6CiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYucmVhZEp1bXBQYXRoID0gcmVhZEp1bXBQYXRoCiAgICAgICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmIui0puWPt1t7c2VsZi5uYW1lfV0g5Yid5aeL5YyW5aSx6LSl77yM6K+35omL5Yqo6K6/6Zeu5LiL56Gu6K6k6aG16Z2i5rKh5bSp5rqDIOaIluiAhSDnqI3lkI7lho3or5XlkKfvvIzkuIDnm7TkuI3ooYzvvIzor7fliY3lvoBUR+e+pOWPjemmiH4gIgogICAgICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBGYWxzZQogICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICBpZiAi5a2Y5Zyo6L+d6KeE5pON5L2cIiBpbiBodG1sdGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOiiq+ajgOa1i+WIsOS6hu+8jOW3sue7j+iiq+Wwge+8jOe7iOatouS7u+WKoe+8jOW/q+WOu+aPkOmGkuWkp+WutuWQp34gIikKICAgICAgICAgICAgICAgICAgICAgICAgc3lzLmV4aXQoMCkKICAgICAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgICAgICBwcmludCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGYi6LSm5Y+3W3tzZWxmLm5hbWV9XSDliJ3lp4vljJblpLHotKXvvIzor7fmiYvliqjorr/pl67kuIvnoa7orqTpobXpnaLmsqHltKnmuoMg5oiW6ICFIOeojeWQjuWGjeivleWQp++8jOS4gOebtOS4jeihjO+8jOivt+WJjeW+gFRH576k5Y+N6aaIfiAiCiAgICAgICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBzZWxmLnJlYWRKdW1wUGF0aCA9ICIvaGFvYmFvYmFvL3d0bXBkb21haW4yIgogICAgICAgICAgICAjICMg6I635Y+W5o+Q546w6aG16Z2i5Zyw5Z2ACiAgICAgICAgICAgIHIgPSByZXF1ZXN0cy5nZXQoCiAgICAgICAgICAgICAgICBmImh0dHA6Ly97c2VsZi5kb21uYWluSG9zdH0vaGFvYmFvYmFvL3dpdGhkcmF3IiwKICAgICAgICAgICAgICAgIGhlYWRlcnM9ewogICAgICAgICAgICAgICAgICAgICJVcGdyYWRlLUluc2VjdXJlLVJlcXVlc3RzIjogIjEiLAogICAgICAgICAgICAgICAgICAgICJVc2VyLUFnZW50IjogI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vc2lnbmVkLWV4Y2hhbmdlO3Y9YjM7cT0wLjkiLAogICAgICAgICAgICAgICAgICAgICAgICAiQWNjZXB0LUVuY29kaW5nIjogImd6aXAsIGRlZmxhdGUiLAogICAgICAgICAgICAgICAgICAgICAgICAiQWNjZXB0LUxhbmd1YWdlIjogInpoLUNOLHpoO3E9MC45IiwKICAgICAgICAgICAgICAgICAgICAgICAgIkNvb2tpZSI6IHNlbGYuQ29va2llLAogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgdmVyaWZ5PUZhbHNlLAogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgaHRtbHRleHQgPSByLnRleHQKICAgICAgICAgICAgICAgIHNpZ25pZGwgPSByZS5zZWFyY2goJ3JlcXVlc3RfaWQgPSAiKC4qPykiJywgaHRtbHRleHQpCiAgICAgICAgICAgICAgICBpZiBzaWduaWRsID09IFtdOgogICAgICAgICAgICAgICAgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XSDlpJrmrKHliJ3lp4vljJYg5o+Q546w5Y+C5pWwIOWksei0pSwg6LSm5Y+35byC5bi477yM6K+35qOA5p+lQ29va2ll77yBIikKICAgICAgICAgICAgICAgICAgICByID0gcmVxdWVzdHMuZ2V0KAogICAgICAgICAgICAgICAgICAgICAgICBmImh0dHBzOi8vY29kZS5zeXdqbWxvdS5jb20uY24vYmFvYmFvY29kZS5waHAiLAogICAgICAgICAgICAgICAgICAgICAgICB2ZXJpZnk9RmFsc2UsCiAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgIHNlbGYuZG9tbmFpbkhvc3QgPSByLmpzb24oKVsiZGF0YSJdWyJsdW9kaSJdLnNwbGl0KCIvIilbMl0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgc2VsZi5yZXF1ZXN0X2lkID0gc2lnbmlkbFsxXQogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgc2VsZi5yZXF1ZXN0X2lkID0gc2lnbmlkbFsxXQogICAgICAgICAgICByZXR1cm4gVHJ1ZQogICAgICAgIGV4Y2VwdCBFeGNlcHRpb24gYXMgZToKICAgICAgICAgICAgIyByYWlzZSBlCiAgICAgICAgICAgIHByaW50KGYi6LSm5Y+3W3tzZWxmLm5hbWV9XeWIneWni+WMluWksei0pSzor7fmo4Dmn6XkvaDnmoRjayIpCiAgICAgICAgICAgIHJldHVybiBGYWxzZQoKICAgIGRlZiBydW4oc2VsZik6CiAgICAgICAgaWYgc2VsZi5pbml0KCk6CiAgICAgICAgICAgIHNlbGYudXNlcl9pbmZvKCkKICAgICAgICAgICAgc2VsZi5nb2xkKCkKICAgICAgICAgICAgaWYgIuebtOaOpeaPkCIgbm90IGluIHNlbGYubmFtZToKICAgICAgICAgICAgICAgIHNlbGYucmVhZCgpCiAgICAgICAgICAgICAgICAjIOWmguaenOaOpeWPo+W0qeS6hu+8jOWwseWwneivleS4ieasoemHjeWQr+mYheivuwogICAgICAgICAgICAgICAgaWYgc2VsZi5yZXRyeVJlYWRpbmcgPT0gVHJ1ZToKICAgICAgICAgICAgICAgICAgICBpZiBteWtreWRSZWFkUHVyZUxvZyA9PSBGYWxzZToKICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe3NlbGYubmFtZX1dIOajgOa1i+WIsOmYheivu+aOpeWPo+W8guW4uO+8jOWwneivlemHjeivlX4iKQogICAgICAgICAgICAgICAgICAgIGZvciBpIGluIHJhbmdlKDMpOgogICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnJlYWQoKQogICAgICAgICAgICAgICAgICAgICAgICAjIOmaj+acuuW7tui/nwogICAgICAgICAgICAgICAgICAgICAgICB0aW1lLnNsZWVwKHJhbmRvbS5yYW5kb20oKSAqIDMgKyAxKQogICAgICAgICAgICAgICAgICAgICAgICBpZiBzZWxmLnJldHJ5UmVhZGluZyA9PSBGY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CcDA0cHNnb044ZE4xRVRfdW84MU5UQzMxIzMwMDAjQVRfVXlJbGJqMjIyMm55bkVTYk0ydkp5QTdEcm1VbVVYRCMxMTY4NgogICAgYWNjb3VudHMgPSBvcy5nZXRlbnYoIm15a2t5ZCIpCiAgICBpbnZpdGVVcmwgPSBnZXROZXdJbnZpdGVVcmwoKQogICAgaWYgYWNjb3VudHMgaXMgTm9uZToKICAgICAgICBwcmludChmIuS9oOayoeacieWhq+WFpW15a2t5ZO+8jOWSi+i/kOihjO+8n1xu6LWw5LiL6YKA6K+35ZGX77yae2ludml0ZVVybH0iKQogICAgZWxzZToKICAgICAgICAjIOiOt+WPlueOr+Wig+WPmOmHj+eahOWAvO+8jOW5tuaMieaMh+WumuWtl+espuS4suWIhuWJsuaIkOWkmuS4qui0puWPt+eahOWPguaVsOe7hOWQiAogICAgICAgIGFjY291bnRzX2xpc3QgPSBvcy5lbnZpcm9uLmdldCgibXlra3lkIikuc3BsaXQoIiYiKQoKICAgICAgICAjIOi+k+WHuuacieWHoOS4qui0puWPtwogICAgICAgIG51bV9vZl9hY2NvdW50cyA9IGxlbihhY2NvdW50c19saXN0KQogICAgICAgIG1vcmVUaXAgPSAiIgogICAgICAgIGlmIHJlYWRQb3N0RGVsYXkgPiAwOgogICAgICAgICAgICBtb3JlVGlwID0gZiLlt7Lorr7nva7nmoTmjqjpgIHmlofnq6DnrYnlvoXngrnlh7vml7bpl7TkuLoge3JlYWRQb3N0RGVsYXl956eSICIKICAgICAgICBwcmludCgKICAgICAgICAgICAgZiLlvZPliY3ohJrmnKzniYjmnKzvvJrlubvnlJ/prZTmlLnoh6rnlKjniYggVjEuNjAgXG7lubvnlJ/mj5DnpLrvvJrojrflj5bliLAge251bV9vZl9hY2NvdW50c30g5Liq6LSm5Y+3IHttb3JlVGlwfVxu5rOo5YaM5Zyw5Z2A77yae2ludml0ZVVybH0iCiAgICAgICAgKQoKICAgICAgICAjIOmBjeWOhuaJgOaciei0puWPtwogICAgICAgIGZvciBpLCBhY2NvdW50IGluIGVudW1lcmF0ZShhY2NvdW50c19saXN0LCBzdGFydD0xKToKICAgICAgICAgICAgIyBwcmludCgiXG4iKQogICAgICAgICAgICBwcmludCgiLSIgKiA1MCkKICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe2FjY291bnQuc3BsaXQoJyMnKVswXX1d5byA5aeL5omn6KGM5Lu75YqhID4+PiIpCiAgICAgICAgICAgICMgcHJpbnQoIlxuIikKICAgICAgICAgICAgIyDmjIlA56ym5Y+35YiG5Ymy5b2T5YmN6LSm5Y+355qE5LiN5ZCM5Y+C5pWwCiAgICAgICAgICAgIHZhbHVlcyA9IGFjY291bnQuc3BsaXQoIiMiKQogICAgICAgICAgICAjIHByaW50KHZhbHVlcykKICAgICAgICAgICAgY2cgPSB7fQogICAgICAgICAgICB0cnk6CiAgICAgICAgICAgICAgICBpZiBsZW4odmFsdWVzKSA9PSAyOgogICAgICAgICAgICAgICAgICAgIGNnID0gewogICAgICAgICAgICAgICAgICAgICAgICAibmFtZSI6IHZhbHVlc1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgIkNvb2tpZSI6IHZhbHVlc1sxXSwKICAgICAgICAgICAgICAgICAgICAgICAgInR4YnoiOiAzMDAwLAogICAgICAgICAgICAgICAgICAgICAgICAiYWxpQWNjb3VudCI6ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAiYWxpTmFtZSI6ICIiLAogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgY2cgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICJuYW1lIjogdmFsdWVzWzBdLAogICAgICAgICAgICAgICAgICAgICAgICAiQ29va2llIjogdmFsdWVzWzFdLAogICAgICAgICAgICAgICAgICAgICAgICAidHhieiI6IHZhbHVlc1syXSBvciAzMDAwLAogICAgICAgICAgICAgICAgICAgICAgICAiYWxpQWNjb3VudCI6ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAiYWxpTmFtZSI6ICIiLAogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiBhcyBlOgogICAgICAgICAgICAgICAgIyDlpITnkIblvILluLgKICAgICAgICAgICAgICAgIHByaW50KCLlubvnlJ/pgLzpgLzlj6g6IiwgIumFjee9rueahOWVpeeOqeaEj++8jOe8uuWPguaVsOS6huaGqOaJue+8jOeci+a4heiEmuacrOivtOaYju+8gSIpCiAgICAgICAgICAgICAgICBjb250aW51ZQogICAgICAgICAgICBjZ1siYXBwVG9rZW4iXSA9ICIiCiAgICAgICAgICAgIGNnWyJ0b3BpY0lkcyJdID0gIiIKICAgICAgICAgICAgIyBwcmludCgi5omL5Yqo77yaIiwgbGVuKHZhbHVlcyksIHZhbHVlc1s0XSkKICAgICAgICAgICAgaWYgbGVuKHZhbHVlcykgPj0gNDoKICAgICAgICAgICAgICAgIGlmIHZhbHVlc1szXToKICAgICAgICAgICAgICAgICAgICBjZ1siYXBwVG9rZW4iXSA9IHZhbHVlc1szXQogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgY2dbImFwcFRva2VuIl0gPSB3eHB1c2hlckFwcFRva2VuCiAgICAgICAgICAgIGlmIGxlbih2YWx1ZXMpID49IDU6CiAgICAgICAgICAgICAgICBpZiB2YWx1ZXNbNF06CiAgICAgICAgICAgICAgICAgICAgY2dbInRvcGljSWRzIl0gPSB2YWx1ZXNbNF0KICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgIGNnWyJ0b3BpY0lkcyJdID0gd3hwdXNoZXJUb3BpY0lkCiAgICAgICAgICAgIGlmIGxlbih2YWx1ZXMpID49IDY6CiAgICAgICAgICAgICAgICBpZiB2YWx1ZXNbNV06CiAgICAgICAgICAgICAgICAgICAgY2dbImFsaU5hbWUiXSA9IHZhbHVlc1s1XQogICAgICAgICAgICBpZiBsZW4odmFsdWVzKSA+PSA3OgogICAgICAgICAgICAgICAgaWYgdmFsdWVzWzZdOgogICAgICAgICAgICAgICAgICAgIGNnWyJhbGlBY2NvdW50Il0gPSB2YWx1ZXNbNl0KICAgICAgICAgICAgdHJ5OgogICAgICAgICAgICAgICAgaWYgd2VjaGF0QnVzc2luZXNzS2V5ID09ICIiOgogICAgICAgICAgICAgICAgICAgIGlmIGNnWyJhcHBUb2tlbiJdLnN0YXJ0c3dpdGgoIkFUXyIpID09IEZhbHNlOgogICAgICAgICAgICAgICAgICAgICAgICBwcmludChmIuW5u+eUn+aPkOekuu+8jOi0puWPt1t7YWNjb3VudC5zcGxpdCgnIycpWzBdfV0gd3hwdXNoIOmFjee9rumUmeivr++8jOW/q+S7lOe7hueci+WktOmDqOivtOaYju+8gSIpCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgICAgICAgICAgICAgaWYgKGNnWyJhcHBUb2tlbiJdLnN0YXJ0c3dpdGgoIkFUXyIpID09IEZhbHNlKSBvciAoCiAgICAgICAgICAgICAgICAgICAgICAgIGNnWyJ0b3BpY0lkcyJdLmlzZGlnaXQoKSA9PSBGYWxzZQogICAgICAgICAgICAgICAgICAgICk6CiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50KGYi5bm755Sf5o+Q56S677yM6LSm5Y+3W3thY2NvdW50LnNwbGl0KCcjJylbMF19XSB3eHB1c2gg6YWN572u6ZSZ6K+v77yM5b+r5LuU57uG55yL5aS06YOo6K+05piO77yBIikKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUKICAgICAgICAgICAgICAgIGFwaSA9IEhIWUQoY2cpCiAgICAgICAgICAgICAgICBpZiBjZ1siYWxpTmFtZSJdIGFuZCBjZ1siYWxpQWNjb3VudCJdOgogICAgICAgICAgICAgICAgICAgIHByaW50KAogICAgICAgICAgICAgICAgICAgICAgICBmIuW5u+eUn+aPkOekuu+8jOi0puWPt1t7YWNjb3VudC5zcGxpdCgnIycpWzBdfV0g6YeH55So5LqGIOaUr+S7mOWuneaPkOeOsO+8jOWnk+WQje+8mntjZ1snYWxpTmFtZSddfe+8jOi0puaIt++8mntjZ1snYWxpQWNjb3VudCddfSIKICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgIHByaW50KGYi5bm755Sf5o+Q56S677yM6LSm5Y+3W3thY2NvdW50LnNwbGl0KCcjJylbMF19XSDph4fnlKjkuoYg5b6u5L+h5o+Q546wIikKICAgICAgICAgICAgICAgIGFwaS5ydW4oKQogICAgICAgICAgICBleGNlcHQgRXhjZXB0aW9uIGFzIGU6CiAgICAgICAgICAgICAgICBwcmludCgKICAgICAgICAgICAgICAgICAgICBmIuW5u+eUn+aPkOekuu+8jOi0puWPt1t7YWNjb3VudC5zcGxpdCgnIycpWzBdfV0g5Ye66ZSZ5ZWm77yM5Lmf6K645piv5bmz5Y+w5o6l5Y+j6Zeu6aKY77yM5Y+v5Lul6L+H5LiA5Lya5bCd6K+V6YeN5paw6L+Q6KGM77yM5aaC5p6c6L+Y5piv5LiN6KGM77yM6K+35bCG5LiL6Z2i5oql6ZSZ5oiq5Zu+5Y+R5YiwdGfkuqTmtYHnvqQ6IgogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgcmFpc2UgZQogICAgICAgICAgICAgICAgY29udGludWUKICAgICAgICAgICAgIyBwcmludCgiXG4iKQogICAgICAgICAgICBwcmludCgiLSIgKiA1MCkKICAgICAgICAgICAgcHJpbnQoZiLotKblj7dbe2FjY291bnQuc3BsaXQoJyMnKVswXX1d5omn6KGM5Lu75Yqh5a6M5q+V77yBIikKICAgICAgICAgICAgIyBwcmludCgiXG4iKQo='))
except Exception as e:
    print('脚本执行出错:', str(e))